#include <iostream>

using namespace std;
typedef unsigned long NUM;

inline NUM T(NUM n){ return (n * (  n + 1)) / 2;	};
inline NUM P(NUM n){ return (n * (3*n - 1)) / 2;	};
inline NUM H(NUM n){ return  n * (2*n - 1);			};

int main()
{
	NUM t = 286, p = 166, h = 144, tt = T(t), pp = P(p), hh = H(h);
	while (tt != hh)
	{
		while (hh != pp)
			if (hh > pp)
				pp = P(++p);
			else
				hh = H(++h);

		if (tt > hh)
			hh = H(++h);
		else
			tt = T(++t);
	}

	cout << tt << endl;
	return 0;
}
